{extends file="index.tpl"} 
{block name="page-content"}
{literal}
<script type="text/javascript">
$(document).ready(function() {
	
	$('input[name="mediumName"]').blur(function() {
		var mediumName=$('input[name="mediumName"]').val();
		var parent=$('select[name="parent"]').val();
		$.ajax({
			type: "GET",
			url: "http://thanhphogame.com/admin/controller/process/ajaxUniqueNameM.php?mediumName="+mediumName,
			data: { mediumName: mediumName, parent: parent }
		}).done(function(res) {
			$('#uniqueName').val(res);
			}
		);              
	});
	$('input[name="unique_name"]').blur(function() {
		var uniqueName=$('input[name="unique_name"]').val();
		var parent=$('select[name="parent"]').val();
		$.ajax({
			type: "GET",
			url: "http://thanhphogame.com/admin/controller/process/ajaxCheckMediumNameM.php?uniqueName="+uniqueName,
			data: { uniqueName: uniqueName, parent: parent }
		}).done(function(res) {
			if (res === 'true'){
				$('#uniqueName').css({"border-color": "red"});
			} else {
				$('#uniqueName').css({"border-color": "#CCC"});
			}
		});                   
	});
	
	$(".addGame").submit(function(){
		
		$.ajax({
			url: 'http://thanhphogame.com/admin/controller/process/ajaxInsertTableGameTemp.php',
		   	type:'POST',
		   	data:$(this).serialize(),
		  	datatype: 'json',
		  	success: function(data){
		   		if(data == 1)
		    	{
		   			$('#updateLongDetailGame').css({'display':'block'});
					alert('thêm thành công');
		    	}
		    	else
		    	{
		     		alert('Kiểm tra dữ liệu nhập');
		    	}
		   	}
		});
		return false;
	});

	$(".updateLongDetailGame").submit(function(){
		$.ajax({
			url: 'http://thanhphogame.com/admin/controller/process/ajaxUpdateLongDetailGameTemp.php',
		   	type:'POST',
		   	data:$(this).serialize(),
		  	datatype: 'text',
		  	success: function(data){
		   		if(data == 1)
		    	{
		   			$('#addGameFull').css({'display':'block'});
					alert('thêm thành công');
		    	}
		    	else
		    	{
		    		alert('Kiểm tra dữ liệu nhập');
		    	}
		   	}
		});
		return false;
	});
	$(".addGameFull").submit(function(){
		$.ajax({
			url: 'http://thanhphogame.com/admin/controller/process/ajaxInsertGameM.php',
		   	type:'POST',
		   	data:$(this).serialize(),
		  	datatype: 'json',
		  	success: function(data){
		   		if(data == 1)
		    	{
					alert('thêm thành công');
					window.location.href="http://thanhphogame.com/admin/index.php?controller=game&action=list&database=mobile";
		    	}
		    	else
		    	{
		    		alert('Kiểm tra dữ liệu nhập');
		    	}
		   	}
		});
		return false;
	});
});          
</script>
{/literal}
<div class="row-fluid">
		<div class="span12">
			<div class="block">
				<div class="head">
					<h2>Thêm Game Mobile</h2>
					<ul class="buttons">
						<li>
							<a href="#" onClick="source('form_validation'); return false;">
								<div class="icon"><span class="ico-info"></span></div>
							</a>
						</li>
					</ul>
				</div>
				<form id="validate" class="addGame" method="POST" action="http://thanhphogame.com/admin/controller/process/ajaxInsertTableGameTemp.php">
					<input type="hidden" class="validate[required]" name="id" value="1"/> 
					<div class="data-fluid">
						
						<div class="row-form">
							<div class="span2">Loại Game</div>
							<div class="span10">
								<select name="loaigame" class="select" style="width: 100%;">
										<option value="2">Game Online</option>
										<option value="3">Game Offline</option>
										<option value="4">Game Web</option>
										<option value="78">Game Kinh Điển</option>
								</select>
							</div>
						</div>
						<!-- <div class="row-form">
							<div class="span2">Kiểu Game Kinh Điển</div>
							<div class="span10">
								<select name="kieugame" class="select" style="width: 100%;">
									<option value="0" >--Chọn kiểu game kinh điển--</option>
									{foreach from=$gamekinhdienArr item=gamekinhdien}
									<option value="{$gamekinhdien.name}" >{$gamekinhdien.name}</option>
                                    {/foreach}
								</select>
							</div>
						</div> --> 
						<div class="row-form">
							<div class="span2">Parent:</div>
							<div class="span10">
								<select name="parent" class="select" style="width: 100%;">
									<option value="0">----Chọn Parent----</option>
									{foreach from=$gameCategoryArr item=gameCategory}
										<option value="{$gameCategory.id}">{$gameCategory.name}</option>
									{/foreach}
								</select>
								
							</div>
						</div>
					
						<div class="row-form">
							<div class="span2">Name</div>
							<div class="span10">
								<input type="text" class="validate[required]" name="name" /> 
								<span class="bottom">Required</span>
							</div>
						</div>
						
						<div class="row-form">
							<div class="span2">Type</div>
							<div class="span3">
                             	<input type="radio" class="validate[required]" checked="checked" name="type" value="1"/> Event
                             	<input type="radio" class="validate[required]" name="type" value="2"/> Hướng dẫn
                          	</div>
						</div>
						<div class="row-form">
							<div class="span2">Medium Name</div>
							<div class="span10">
								<input type="text" class="" name="mediumName" id="mediumName"/> 
								<span class="bottom">Required</span>
							</div>
						</div>  
						<div class="row-form">
							<div class="span2">Unique Name</div>
							<div class="span10">
								<input type="text" id="uniqueName" name="unique_name"/> 
							</div>
						</div>  
						<div class="row-form">
							<div class="span2">SEO Name</div>
							<div class="span10">
								<input type="text" name="SEO_Name"/>
							</div>
						</div>
						<div class="row-form">
							<div class="span2">Image</div>
							<div class="span10">
								<input type="text" class="validate[required]" name="image" /> 
								<span class="bottom">Required</span>
							</div>
						</div>
						<div class="row-form">
							<div class="span2">XLarge Image</div>
							<div class="span10">
								<input type="text" name="xlargeImage" />
							</div>
						</div>
						<div class="row-form">
							<div class="span2">Sort Detail</div>
							<div class="span10"><textarea name="shortDetail" placeholder="Placeholder example" class="validate[required]"></textarea></div>
						</div>
						<div class="row-form">
							<div class="span2">Medium Detail</div>
							<div class="span10"><textarea name="mediumDetail" placeholder="Placeholder example" class="validate[required]"></textarea></div>
						</div>
						<div class="row-form">
							<div class="span2">SEO_metaDescription</div>
							<div class="span10"><textarea name="SEO_metaDescription" placeholder="Placeholder example" class="validate[required]"></textarea></div>
						</div>
						<div class="row-form">
							<div class="span2">SEO_keyword</div>
							<div class="span10"><input name="SEO_keyword" type="text" class="tags"/></div>
						</div>
						 
						
						<div class="row-form">
							<div class="span2">Hot Star:</div>
							<div class="span10">
								<select name="hot_star" class="select" style="width: 100%;">
									<option value="0">Ẩn</option>
									<option value="5">Hiện</option>
								</select>
							</div>
						</div>
						<div class="row-form">
							<div class="span2">Is Event:</div>
							<div class="span10">
								<select name="isEvent" class="select" style="width: 100%;">
									<option value="1">Hiện</option>
									<option value="0">Ẩn</option>
									
								</select>
							</div>
						</div>
	                    <div class="row-form">
	                    	<div class="span2">Expire Date</div>
	                    	<div class="span10"> 
	                    		<input type="text" name="expire_date" class="datepicker"/>
	                    		<span class="bottom">date YYYY-MM-DD</span>
	                    	</div>
	                    </div>
	                    <div class="row-form">
							<div class="span2">Link Canonical</div>
							<div class="span10"><textarea name="link_canonical" placeholder="Placeholder example"></textarea></div>
						</div>
	                    <!--<div class="row-form">
							<div class="span2">Tag Game:</div>
							<div class="span10">
								<select name="tag1[]" multiple="multiple" class="select" style="width: 100%;">
									<option value="0">choose a option...</option>
										{foreach from=$gameTagArr item=gameTag}
		                                	<option value="{$gameTag.id}">{$gameTag.name}</option>
		                                {/foreach}
								</select>
							</div>
						</div>
						<div class="row-form">
							<div class="span2">SEO_title</div>
							<div class="span10"><textarea name="SEO_title" placeholder="Placeholder example"></textarea></div>
						</div>
						<!-- <div class="row-form">
               				<div class="span12">
               					<span class="top title">Tag Game:</span>
               					<select name="tag1[]" multiple="multiple" id="msc">
                                	{foreach from=$gameTagArr item=gameTag}
	                                	<option value="{$gameTag.id}">{$gameTag.name}</option>
	                                {/foreach}
                                </select>
                            	<div class="btn-group">
                             		<button class="btn btn-mini" id="ms_select">Select all</button>
                             		<button class="btn btn-mini" id="ms_deselect">Deselect all</button>
                               	</div>
                         	</div>                    
                      	</div>  -->
						<div class="toolbar bottom tar">
							<div class="btn-group">
								<button class="btn btn-info" type="button" onClick="$('#validate').validationEngine('hide');">Hide prompts</button>
                                <button class="btn" type="submit" id="addGame">Thêm Game</button>
                            </div>
                       	</div>
					</div>
					
				</form>
				<form id="validate"  class="updateLongDetailGame" method="POST" action="http://thanhphogame.com/admin/controller/process/ajaxUpdateLongDetailMGameTemp.php">
					<div class="data-fluid">
						<div class="block">
	                        <div class="head green">                                
	                            <h2>Long Detail</h2>               
	                        </div>
	                        <textarea id="elrte" name="longDetail" cols="auto" rows="auto" style="height: 500px !important"></textarea>
	                    </div>  
						<button class="btn" type="submit" style="display: none;" id="updateLongDetailGame">Thêm LongDetail</button>
					</div>
					
				</form>
				
				<form id="validate" class ='addGameFull' method="POST" action="http://thanhphogame.com/admin/controller/process/ajaxInsertGameM.php">
					<div class="data-fluid">
						<div class="toolbar bottom tar">
							<div class="btn-group" style="display: none;" id ='addGameFull'>
								<button class="btn btn-info" type="button" onClick="$('#validate').validationEngine('hide');">Hide prompts</button>
                                <button class="btn" type="submit">Thêm Game Full</button>
                            </div>
                       	</div>
					</div>
					
				</form>
			</div>
		</div>
	</div>
	

{/block}

